//
//  UCTabBarSetting.swift
//  UICreate
//
//  Created by 范晓鑫 on 2021/10/27.
//

import UIKit

extension UCSetting where TargetType: UITabBar {
    ///样式
    public static func style(_ style: UIBarStyle) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.barStyle = style
        })
    }
    ///delegate
    public static func delegate(_ delegate: UITabBarDelegate?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.delegate = delegate
        })
    }
    ///items
    public static func items(_ items: [UITabBarItem]?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.items = items
        })
    }
    ///selectedItem
    public static func selected(_ item: UITabBarItem?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.selectedItem = item
        })
    }
    ///barTintColor
    public static func tint(bar color: UIColor?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.barTintColor = color
        })
    }
    ///unselectedItemTintColor
    public static func tint(unselected color: UIColor?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.unselectedItemTintColor = color
        })
    }
    ///selectedImageTintColor
    @available(iOS, introduced: 5.0, deprecated: 8.0)
    public static func tint(selected color: UIColor?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.selectedImageTintColor = color
        })
    }
    ///backgroundImage
    public static func bg(_ image: UIImage?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.backgroundImage = image
        })
    }
    ///selectionIndicatorImage
    public static func selected(_ image: UIImage?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.selectionIndicatorImage = image
        })
    }
    ///shadowImage
    public static func shadow(_ image: UIImage?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.shadowImage = image
        })
    }
    ///itemPositioning
    public static func item(position: UITabBar.ItemPositioning) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.itemPositioning = position
        })
    }
    ///itemWidth
    public static func item(width: CGFloat) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.itemWidth = width
        })
    }
    ///itemSpacing
    public static func item(spacing: CGFloat) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.itemSpacing = spacing
        })
    }
    ///半透明
    public static func translucent(_ translucent: Bool = true) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.isTranslucent = translucent
        })
    }
    ///standardAppearance
    @available(iOS 13.0, *)
    public static func appearance(_ standard: UITabBarAppearance) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.standardAppearance = standard
        })
    }
    ///standardAppearance
    @available(iOS 15.0, *)
    public static func appearance(scroll: UITabBarAppearance?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.scrollEdgeAppearance = scroll
        })
    }
}
